<template>
  <DataList :cate="cate" :name="name" :single="true" :cols="cols" />
</template>
<script>
import DataList from "@/components/DataList";
import { getUser } from "@/utils/auth";
import { addZxs, deleteZxs, updateZxs, getZxs } from "@/api/当年9月1日前在校生.js";
import {  get在校生信息 } from "@/api/在校生信息.js";
import linq from "linq"
export default {
  components: {
    DataList
  },
  data() {
    return {
      cate: "A1-5 当年9月1日前在校生",
      name:'1.5 当年9月1日前在校生',
      
      cols: [
       { label: "折合在校生数(人)", prop: "ZHZXS" },
       { label: "全日制学历教育在校生数(人)", prop: "QRZZXS" },
       { label: "全日制普通高职学历教育在校生总数(人)", prop: "GZ_ZS" },  

       { label: "其中",
       data:[
            { label: "高中起点", prop:"GZ_GZQD" },
            { label: "中职起点", data:[
                { label: "合计", prop: "GZ_ZZHJ" },
                { label: "其中：五年制后二年", prop: "GZ_ZZWNZ" }
                ]
            },
            { label:"其他", prop: "GZ_QT" }
            ]
       },
       {  label: "全日制普通中职学历教育在校生(人)", 
       data:[
            { label: "合计", prop: "ZZ_ZS" },
            { label: "其中：五年制前三年", prop: "ZZ_WNZ" },
            { label: "其中：新型职业农民", prop: "ZZ_NM" }
            ]
       },
       { label: "全日制成人高职在校生(人)", prop: "CRGZ" },
       { label: "全日制成人中职在校生(人)", prop: "CRZZ" },
       { label: "非全日制专科学历教育注册生(人)", prop: "FQRZZK" },
       { label: "非全日制本科学历教育注册生(人)", prop: "FQRZBK" },
       { label:"培训规模(人天)",
       data:[
            {label:"社会",prop:"PXGM_SH"},
            {label:"在校生",prop:"PXGM_ZXS"}
            ]
       },
       { label:"培训对象(人次)",
       data:[
            {label:"特定群体",prop:"PXDX_TDQT"},
            {label:"小微企业",prop:"PXDX_XWQY"}
            ]
        },
       { label:"留学生(人)",
       data:[
            {label:"境外",prop:"LXS_JW"},
            {label:"国外",prop:"LXS_GW"}
            ]
       },
       { label: "预科生、进修生、成人脱产班学生合计(人)", prop: "YKS" },
       { label: "夜大(业余)学生数(人)", prop: "YDYY" },
       { label: "函授生(人)", prop: "HSS" },
       
      ]
    };
  },        
  methods:{
      async  onChange(model, field, value) {
        var user = getUser()   
    
        model.ZHZXS = (Number(model.GZ_ZS)+(Number(model.LXS_JW)+Number(model.LXS_GW))*3+Number(model.YKS)+Number(model.YDYY)*0.3+Number(model.HSS)*0.1).toFixed(2)+'';
         model.QRZZXS = (Number(model.GZ_ZS)+Number(model.LXS_JW)+Number(model.LXS_GW)+Number(model.YKS)).toFixed(2)+'';
         
        model.GZ_GZQD=linq.from(f).where(`$.XZ_SYLX == '普通高中生'&&($.XZ_XJZT=='在读'||$.XZ_XJZT=='毕业')`).count()+'';
        model.GZ_ZZHJ=linq.from(f).where(`$.XZ_SYLX == '"三校生"'||$.XZ_SYLX == '"3+2"'||$.XZ_SYLX == '"五年制高职"'&&($.XZ_XJZT=='在读'||$.XZ_XJZT=='毕业')`).count()+'';
        model.GZ_ZZWNZ=linq.from(f).where(`$.XZ_XZ == '五年制'&&$.XZ_SYLX == '"五年制高职"'&&($.XZ_NJ =='2013级'||$.XZ_NJ =='2014级')&&($.XZ_XJZT=='在读'||$.XZ_XJZT=='毕业')`).count()+'';
        model.GZ_QT=linq.from(f).where(`$.XZ_SYLX == '其他'&&$.XZ_XJZT=='在读'||$.XZ_XJZT=='毕业'`).count()+'';
       model.GZ_ZS =Number(model.GZ_GZQD)+Number(model.GZ_ZZHJ)+Number(model.GZ_QT)+'';
         
      //
    },
    async fetchData() {
      var user = getUser();       
      
      var datas = await getZxs(user.XXID,user.CJPC);
     
      return datas;
    },     
    onadd(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
      
          console.log(JSON.stringify(temp));
          var model = await addZxs(temp);
          resolve(model);
      })
      
    },
    onupdate(model) {
      //
      var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
           
          console.log(JSON.stringify(temp));
          var model = await updateZxs(temp);
          resolve(model);
      })
      //
    },
    ondelete(model) {
       var temp = JSON.parse(JSON.stringify(model))
      return new Promise(async (resolve,reject)=>{
        
         await deleteZxs(temp);
          resolve();
      })
    }
        }
};
</script>
<style>
</style>